﻿namespace Common.Localization
{
    using System.Globalization;

    public enum Language { Ua, Ru, En }

    public static class LocalizationProvider
    {
        private static Language lang;

        public static Language Language
        {
            get
            {
                return LocalizationProvider.lang;
            }
            set
            {
                LocalizationProvider.lang = value;
                CultureInfo culture = new CultureInfo("en-US");
                switch (LocalizationProvider.lang)
                {
                    case Language.Ru:
                    {
                        culture = new CultureInfo("ru-RU");
                        break;
                    }
                    case Language.Ua:
                    {
                        culture = new CultureInfo("uk");
                        break;
                    }
                }

                //System.Threading.Thread.CurrentThread.CurrentCulture = culture;
                //System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
            }
        }

        public static string GetMessage(string key)
        {
            switch (LocalizationProvider.Language)
            {
                case Language.En:
                    {
                        string s = Resources.ResEN.ResourceManager.GetString(key);
                        if (s != null)
                        {
                            return s;
                        }

                        break;
                    }
                case Language.Ua:
                    {
                        string s = Resources.ResUA.ResourceManager.GetString(key);
                        if (s != null)
                        {
                            return s;
                        }

                        break;
                    }
                case Language.Ru:
                    {
                        string s = Resources.ResRU.ResourceManager.GetString(key);
                        if (s != null)
                        {
                            return s;
                        }

                        break;
                    }
            }

            return key;
        }
    }
}